﻿using DXApplicationTangche.UC.工序管理.service;
using DXApplicationTangche.UC.生产下单;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace DXApplicationTangche.UC.工序管理.工序门户
{
    public partial class Form成衣工序扫码情况 : DevExpress.XtraEditors.XtraForm
    {
        public Form成衣工序扫码情况()
        {
            InitializeComponent();
            this.入库刷新();
            this.裁剪刷新();
            //加载销售日记账导出BOM
            Form生产下单订单门户 form生产下单订单门户 = new Form生产下单订单门户();
            form生产下单订单门户.TopLevel = false;
            form生产下单订单门户.Dock = DockStyle.Fill;
            form生产下单订单门户.FormBorderStyle = FormBorderStyle.None;
            this.panel1.Controls.Clear();
            this.panel1.Controls.Add(form生产下单订单门户);
            form生产下单订单门户.Show();
        }
        private void 入库刷新()
        {
            List<StockInWipRecordDTO> stockInWipRecordDTOs = new List<StockInWipRecordDTO>();
            stockInWipRecordDTOs = 工序Service.getDailyStockInWipRecord();
            this.gridControl成衣入库.DataSource = stockInWipRecordDTOs;
            this.gridView成衣入库.RefreshData();
        }
        private void 裁剪刷新()
        {
            List<WashingMarkWipRecodeDTO> washingMarkWipRecodeDTOs = new List<WashingMarkWipRecodeDTO>();
            washingMarkWipRecodeDTOs = 工序Service.getDailyWashingMarkWipRecode();
            this.gridControl成衣裁剪.DataSource = washingMarkWipRecodeDTOs;
            this.gridView成衣裁剪.RefreshData();
        }

        private void simpleButton裁剪刷新_Click(object sender, EventArgs e)
        {
            this.裁剪刷新();
        }

        private void simpleButton裁剪导出excel_Click(object sender, EventArgs e)
        {
            SaveFileDialog fileDialog = new SaveFileDialog();
            fileDialog.Title = "导出最近两天投产水洗的全部裁剪记录";
            fileDialog.Filter = "Excel文件(*.xlsx)|*.xlsx";
            DialogResult dialogResult = fileDialog.ShowDialog(this);
            if (dialogResult == DialogResult.OK)
            {
                DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions();
                this.gridView成衣裁剪.ExportToXlsx(fileDialog.FileName);
                DevExpress.XtraEditors.XtraMessageBox.Show("文件已保存至" + fileDialog.FileName, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }

        private void simpleButton入库刷新_Click(object sender, EventArgs e)
        {
            this.入库刷新();
        }

        private void simpleButton入库导出excel_Click(object sender, EventArgs e)
        {
            SaveFileDialog fileDialog = new SaveFileDialog();
            fileDialog.Title = "导出最近两天入库产成品的全部工序记录";
            fileDialog.Filter = "Excel文件(*.xlsx)|*.xlsx";
            DialogResult dialogResult = fileDialog.ShowDialog(this);
            if (dialogResult == DialogResult.OK)
            {
                DevExpress.XtraPrinting.XlsExportOptions options = new DevExpress.XtraPrinting.XlsExportOptions();
                this.gridView成衣入库.ExportToXlsx(fileDialog.FileName);
                DevExpress.XtraEditors.XtraMessageBox.Show("文件已保存至" + fileDialog.FileName, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }

    }
}
